#include<iostream>
#include<mutex>
#include<string>
#include<memory>
class some_big_object{};
void swap(some_big_object&lhs, some_big_object&rhs)
{
	std::swap(lhs, rhs);
}
class X {
public:
	X(const some_big_object&sd):some_detail(sd){}
	friend void swap(X&lhs, X&rhs)
	{
		if (&lhs == &rhs)
			return;
		std::unique_lock<std::mutex> lock_a(lhs.m, std::defer_lock);//1
		std::unique_lock<std::mutex> lock_b(rhs.m, std::defer_lock);
		std::lock(lock_a, lock_b);//2
		swap(lhs.some_detail, rhs.some_detail);
	}
private:
	some_big_object some_detail;
	std::mutex m;
};
int main()
{
	std::cout << "Hello World" << std::endl;
}